package com.four.peoplemanage.holiday.controller;

import com.four.peoplemanage.common.bean.ResponseData;
import com.four.peoplemanage.common.controller.BaseController;
import com.four.peoplemanage.holiday.entity.Holiday;
import com.four.peoplemanage.holiday.service.HolidayService;
import com.four.peoplemanage.information.entity.Information;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/holiday")
public class HolidayController extends BaseController {
    @Autowired
    private HolidayService holidayService;

    //查看
    @GetMapping("/canAll")
    public ResponseData<Object> getPeople(
            @RequestParam("pageNum") int pageNum,
            @RequestParam("pageSize") int pageSize,
            @RequestParam(value = "holiday_name",required = false) String holiday_name,
            @RequestParam(value = "datetm",required = false) String datetm
    ){
        return returnObject(holidayService.getOnrePage(pageNum,pageSize,holiday_name,datetm));
    }

    //添加
    @PostMapping("/add")
    public ResponseData<Boolean> add(Holiday holiday){
        return returnBoolean(holidayService.addHoliday(holiday));
    }

    //修改
    @PutMapping("/update")
    public ResponseData<Boolean> update(@RequestBody Holiday holiday){
        return returnBoolean(holidayService.updateHoliday(holiday));
    }

    //删除
    @DeleteMapping("/del/{id}")
    public ResponseData<Boolean> del(@PathVariable("id") Integer id){
        return returnBoolean(holidayService.delHoliday(id));
    }
}
